package com.kenans.service.impl;

import com.kenans.common.JsonResult;
import com.kenans.dao.UserDao;
import com.kenans.entity.User;
import com.kenans.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author KENANS
 * @date 2020-8-26 14:28
 * @Version 1.0
 */
@Service
public class UserServiceImpl implements UserService {
    @Autowired
    private UserDao userDao;

    @Override
    public User login(User user) {
        User login = userDao.findByTel(user.getTel());
        if (login == null) {
            new RuntimeException("账号错误！");
        } else {
            if (!user.getPassword().equals(login.getPassword())) {
                new RuntimeException("密码错误");
            }
        }
        return login;
    }

    @Override
    public void addUser(User user) {
        userDao.addUser(user);
    }

    @Override
    public List<User> findAll() {
        return userDao.findAll();
    }
}
